#pragma once
#include "base_common_file.h"
#include "base_common_str.h"
#include "base_common_system.h"

void zero_memory( void * buf, size_t len );
size_t HexStringToBytes( const byte * input, size_t in_len, byte * output, size_t out_len );
string BytesToHexString( const byte * input, size_t in_len );
void   MakeLower( char_t * p );
void   MakeUpper( char_t * p );
void   MakeUpper( string_t & str );
int    AnsiToUnicode( castr_t inBuf, int nInLen, wchar_t * outBuf, int nOutLen );
int    UnicodeToAnsi( cwstr_t inBuf, int nInLen, char * outBuf, int nOutLen );
int    AnsiToUtf8( char * inBuf, int nInLen, char * outBuf, int nOutLen );
int    Utf8ToAnsi( char * inBuf, int nInLen, char * outBuf, int nOutLen );
int    Utf8ToUnicode( char * inBuf, int nInLen, wchar_t * outBuf, int nOutLen );
int    UnicodeToUtf8( wchar_t * inBuf, int nInLen, char * outBuf, int nOutLen );

void unicode_to_ansi( wstring_t wstr, astring_t &astr );
void unicode_to_utf8( wstring_t wstr, astring_t &astr );
void ansi_to_unicode( astring_t astr, wstring_t &wstr );
void utf8_to_unicode( astring_t astr, wstring_t &wstr );

bool   StringToGUID( cstr_t lpszGuid, LPGUID guid );
bool   GUIDToString( GUID & guid, string_t strGUID );

bool   GetDiskFreeSpace( cstr_t lpszDriver, uint64 & nFreeSpace );
char * Domain2Ip(const char * lpszDomain);
void   BaseZeroMemory( void * buf, uint32 len );
uint32 BaseHexStringToBytes( const byte * input, uint32 in_len, byte * output, uint32 out_len );
string BaseBytesToHexString( const byte * input, uint32 in_len );

void BaseMakeLowerA( char * p );
void BaseMakeUpperA( char * p );
void BaseMakeLowerW( wchar_t * p );
void BaseMakeUpperW( wchar_t * p );

int  BaseAnsiToUnicode( castr_t inBuf, int nInLen, wchar_t * outBuf, int nOutLen );
int  BaseUnicodeToAnsi( cwstr_t inBuf, int nInLen, char * outBuf, int nOutLen );
int  BaseAnsiToUtf8( char * inBuf, int nInLen, char * outBuf, int nOutLen );
int  BaseUtf8ToAnsi( char * inBuf, int nInLen, char * outBuf, int nOutLen );
int  BaseUtf8ToUnicode( char * inBuf, int nInLen, wchar_t * outBuf, int nOutLen );
int  BaseUnicodeToUtf8( wchar_t * inBuf, int nInLen, char * outBuf, int nOutLen );


void base_unicode_to_ansi( wstring_t wstr, astring_t &astr );
void base_unicode_to_utf8( wstring_t wstr, astring_t &astr );
void base_ansi_to_unicode( astring_t astr, wstring_t &wstr );
void base_utf8_to_unicode( astring_t astr, wstring_t &wstr );

#if defined(_UNICODE)
#define BaseMakeLower BaseMakeLowerW
#define BaseMakeUpper BaseMakeUpperW
#else
#define BaseMakeLower BaseMakeLowerA
#define BaseMakeUpper BaseMakeUpperA
#endif